package com.maltys.dynamicdatasource.common.dynamic;

import com.maltys.dynamicdatasource.common.context.DynamicDataSourceContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

@Slf4j
public class DynamicDataSource extends AbstractRoutingDataSource {
    @Override
    protected Object determineCurrentLookupKey() {
        String contextKey = DynamicDataSourceContext.getContextKey();
        log.info("current data source key:{}", contextKey);
        return contextKey;
    }
}
